<template>
	<div>
		<el-card class="box-card">
		  <div slot="header" class="clearfix">
		    <span>分类列表</span>
		    <el-button style="float: right; padding: 3px 0" type="text">添加</el-button>
		  </div>
		  
		  <el-table
		      :data="tableData"
		      border
		      style="width: 100%">
		      <el-table-column
		        prop="create_time"
		        label="日期"
		        width="180">
		      </el-table-column>
		      <el-table-column
		        prop="title"
		        label="标题"
		        width="180">
		      </el-table-column>
		      <el-table-column
		        label="操作">
					<template slot-scope="scope">
						<el-button type="primary">编辑</el-button>
						<el-button type="danger" @click="del(scope.row.id)">删除</el-button>
					</template>
		      </el-table-column>
		    </el-table>
		</el-card>
	</div>
</template>

<script>
	export default{
		data() {
			return {
				 tableData: [],
			}
		},
		created() {
			this.getList()
		},
		methods:{
			
			async getList(){
				const{data:res} = await this.$ajax.get('http://api.io/api/Cate/index')
				this.tableData = res.data
				console.log(res)
				
			},
			
			async del(id){
				const{data:res} = await this.$ajax.get('http://api.io/api/Cate/delete',{params:{id:id}})
				if(res.code==1){
					this.$msg.success(res.msg)
					this.getList()
				}else{
					this.$msg.error(res.msg)
				}
				console.log(res)
			}
		}
	}
</script>

<style>
</style>
